﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

#pragma once

#include "GcmpDwgDxfInterface.h"
#include "RuntimeId.h"

namespace gcmp
{
    class IError;
    class IErrorCode;
    class IDocument;


    class GCMP_DWG_DXF_INTERFACE_EXPORT IErrorManager
    {
    public:
        /// \brief 创建IErrorManager实例
        /// \param pDoc  文档指针
        /// \return 返回IErrorManager实例的指针
        static IErrorManager* CreateErrorManager(IDocument* pDoc);

        /// \brief 获取IErrorManager实例
        /// \param docId  文档id
        /// \return 返回IErrorManager实例的指针，如果没有则返回nullptr
        /// \note 如果不传docId或者传入的Id为无效值，返回当前文档的ErrorManager
        static IErrorManager* GetErrorManager(RuntimeId docId = RuntimeId::InvalidID);

        /// \brief 添加error
        /// \param pErrorCode  errorCode指针
        /// \param errorMsg 错误描述信息
        /// \return 添加成功返回true，否则返回false
        /// \note 这里会使用平台默认的IError实现类
        static bool AddError(OwnerPtr<IErrorCode> pErrorCode, const std::wstring& errorMsg);

        /// \brief 添加Error
        /// \return void
        virtual void AddError(OwnerPtr<IError> pError) = 0;

        /// \brief 清空Error
        /// \return void
        virtual void ClearErrors() = 0;

        /// \brief 是否有error
        /// \return 如果没有error返回true，否则返回false
        virtual bool IsEmpty() const = 0;

        /// \brief 获取所有Error
        /// \return error的vector数组
        virtual const std::vector<OwnerPtr<IError>>& GetAllErrors() const = 0;

        /// \brief 将所有错误的描述组成一个字符串返回给用户，如
        /// error 1： 非法参数
        /// error 2:  数据为空
        virtual std::wstring GetErrorsDescription() const = 0;
    };

}
